
*Set path here

use "mergeall", clear

******************************************
************ ANALYSIS *******************
******************************************

***********************
****** Multilevel *****
***********************

drop part_badge

**************************************
*** MODELS WITH UNEMPLOYMENT       ***
**************************************

***Figure 2 Likelihood of Participating in a Demonstration in 26 Countries, 2006–2014 

eststo: xtmixed part_demon ib5.ideol5 ib1.gender i.age_r i.h_incomecat i.edu_high pol_interest i.close_party c.unemployment i.year || c_num:
margins, at(ideol5=(1(1)5))
marginsplot, title("Ideology") ytitle("") xtitle("") sch(s1mono) name(_ideology_demon, replace)

margins, at(gender=(0 1))
marginsplot, title("Gender") xtitle("") ytitle("") sch(s1mono) name(_female_demon, replace)

margins, at(age_r=(1(1)4))
marginsplot, title("Age") xtitle("") ytitle("") sch(s1mono) name(_age_demon, replace)

margins, at(h_incomecat=(1 2 3))
marginsplot, title("Income") xtitle("") ytitle("") sch(s1mono) name(_income_demon, replace)

margins, at(edu_high=(0 1))
marginsplot, title("Education") xtitle("") ytitle("") sch(s1mono) name(_education_demon, replace)

graph combine _ideology_demon _female_demon _age_demon _income_demon _education_demon, sch(s1mono) col(2) iscale(*0.9) name(figure2, replace)
graph export figure2.pdf, replace


***Figure 3 Likelihood of Engaging in Low-Cost Participation in 26 Countries, 2006–2014 

eststo: xtmixed part_low2 ib5.ideol5 ib1.gender i.age_r i.h_incomecat i.edu_high pol_interest i.close_party c.unemployment i.year || c_num:
margins, at(ideol5=(1(1)5))
marginsplot, title("Ideology") xtitle("") ytitle("") sch(s1mono) name(_ideology_low, replace)

margins, at(gender=(0 1))
marginsplot, title("Gender") xtitle("") ytitle("") sch(s1mono) name(_female_low, replace)

margins, at(age_r=(1(1)4))
marginsplot, title("Age") xtitle("") ytitle("") sch(s1mono) name(_age_low, replace)

margins, at(h_incomecat=(1 2 3))
marginsplot, title("Income") xtitle("") ytitle("") sch(s1mono) name(_income_low, replace)

margins, at(edu_high=(0 1))
marginsplot, title("Education") xtitle("") ytitle("") sch(s1mono) name(_education_low, replace)

graph combine _ideology_low _female_low _age_low _income_low _education_low, sch(s1mono)col(2) iscale(*0.9) name(figure3, replace)
graph export figure3.pdf, replace


*Figure 4 Change in the Likelihood of Engaging in High and Low-Cost Protesting When Moving from a Country with Minimum to Maximum Level of Unemployment 

*Run the code and copy the marginal effects and CI on a separate excel to create the figure

*First models for high-cost protest
eststo: xtmixed part_demon ib5.ideol5##c.unemployment ib1.gender ib4.age_r i.h_incomecat i.edu_high pol_interest i.close_party  i.year || c_num: // ideol

forval i = 1/5 {
margins, at(unemployment=(3 25) ideol5=(`i')) pwcompare
}

eststo: xtmixed part_demon ib5.ideol5 ib1.gender##c.unemployment ib4.age_r i.h_incomecat i.edu_high pol_interest i.close_party  i.year || c_num: // gender

forval i = 0/1 {
margins, at(unemployment=(3 25) gender=(`i')) pwcompare
}

eststo: xtmixed part_demon ib5.ideol5 ib1.gender ib4.age_r##c.unemployment i.h_incomecat i.edu_high pol_interest i.close_party  i.year || c_num: // age

forval i = 1/4 {
margins, at(unemployment=(3 25) age_r=(`i')) pwcompare
}

eststo: xtmixed part_demon ib5.ideol5 ib1.gender ib4.age_r i.h_incomecat##c.unemployment i.edu_high pol_interest i.close_party  i.year || c_num: // incomecat

forval i = 1/3 {
margins, at(unemployment=(3 25) h_incomecat=(`i')) pwcompare
}

eststo: xtmixed part_demon ib5.ideol5 ib1.gender ib4.age_r i.h_incomecat i.edu_high##c.unemployment pol_interest i.close_party  i.year || c_num: // education

forval i = 0/1 {
margins, at(unemployment=(3 25) edu_high=(`i')) pwcompare
}


*Now low-cost protest models

eststo: xtmixed part_low2 ib5.ideol5##c.unemployment ib1.gender ib4.age_r i.h_incomecat i.edu_high pol_interest i.close_party  i.year || c_num: // ideol

forval i = 1/5 {
margins, at(unemployment=(3 25) ideol5=(`i')) pwcompare
}

eststo: xtmixed part_low2 ib5.ideol5 ib1.gender##c.unemployment ib4.age_r i.h_incomecat i.edu_high pol_interest i.close_party  i.year || c_num: // gender

forval i = 0/1 {
margins, at(unemployment=(3 25) gender=(`i')) pwcompare
}

eststo: xtmixed part_low2 ib5.ideol5 ib1.gender ib4.age_r##c.unemployment i.h_incomecat i.edu_high pol_interest i.close_party  i.year || c_num: // age

forval i = 1/4 {
margins, at(unemployment=(3 25) age_r=(`i')) pwcompare
}

eststo: xtmixed part_low2 ib5.ideol5 ib1.gender ib4.age_r i.h_incomecat##c.unemployment i.edu_high pol_interest i.close_party  i.year || c_num: // incomecat

forval i = 1/3 {
margins, at(unemployment=(3 25) h_incomecat=(`i')) pwcompare
}

eststo: xtmixed part_low2 ib5.ideol5 ib1.gender ib4.age_r i.h_incomecat i.edu_high##c.unemployment pol_interest i.close_party  i.year || c_num: // education

forval i = 0/1 {
margins, at(unemployment=(3 25) edu_high=(`i')) pwcompare
}

*Estimates are copied on figure4.xlsx. To reproduce the figure, use Figure 4.R
